package com.qushiyun.devops.admin.sync.data.po;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qushiyun.devops.common.framework.mybatis.typehanlder.FastJsonArrayTypeHandler;
import java.util.Date;
import java.util.Objects;
import lombok.Data;

/**
 * 同步任务
 *
 * @author zhouzx
 */
@Data
@TableName("sync_trigger_job")
public class TriggerJob {

	@TableId(type = IdType.AUTO)
	private Long id;
	private Long conditionId;

	private String name;
	private Integer type;

	private int startIndex = 0;

	private Integer syncType;

	@TableField(typeHandler = FastJsonArrayTypeHandler.class)
	private JSONArray jobIds;

	private String tenantId;

	/**
	 * 每次同步数量
	 */
	private Integer step;

	private Integer triggerType;
	private Date triggerTime;
	private Long triggerTimestamp;

	/**
	 * 时间间隔
	 */
	@TableField("`interval`")
	private Long interval;


	private Integer status;

	@TableField(typeHandler = FastJsonArrayTypeHandler.class)
	private JSONArray toNacos;
	private String config;

	private Long fromDb;
	private Long toDb;
	private String fromDbBeforeSql;
	private String fromDbAfterSql;
	private String toDbBeforeSql;
	private String toDbAfterSql;
	private String fromDbErrorSql;
	private String toDbErrorSql;

	private String errorMsg;
	private Integer tableNum;
	private Long dataNum;

	private String remark;


	@TableField(typeHandler = FastJsonArrayTypeHandler.class)
	private JSONArray tableList;

	@TableLogic(value = "0")
	private Integer delFlag;

	private Long costTime;
	private Date createTime;
	private Date updateTime;

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		TriggerJob that = (TriggerJob) o;
		return Objects.equals(id, that.id);
	}

	@Override
	public int hashCode() {
		return Objects.hash(id);
	}
}